﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using AvalonDock.Layout.Serialization;

namespace 多协议通信平台.Views.Protocal
{
    /// <summary>
    /// Mc3eView.xaml 的交互逻辑
    /// </summary>
    public partial class Mc3eView : UserControl
    {
        public Mc3eView()
        {
            InitializeComponent();
            Loaded += Mc3eView_Loaded;
        }

        private string _initialLayout;

        private void Mc3eView_Loaded(object sender, RoutedEventArgs e)
        {
            XmlLayoutSerializer serializer = new XmlLayoutSerializer(dockingManager);
            using (var writer = new StringWriter())
            {
                serializer.Serialize(writer);
                _initialLayout = writer.ToString();
            }
        }


        private void ResetLayout(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrEmpty(_initialLayout))
            {
                var serializer = new XmlLayoutSerializer(dockingManager);
                using (var reader = new StringReader(_initialLayout))
                {
                    serializer.Deserialize(reader); // 恢复到初始状态
                }
            }
        }

        private void Button_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            Button? btn = sender as Button;
            btn1.IsEnabled = btn.IsEnabled ? false : true;
        }
    }
}
